package com.base.cn.platform.os.entity.order.order;

import com.base.cn.platform.os.common.mybatis.BaseEntity;
import com.base.cn.platform.os.common.utils.StringUtils;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 图片订单扩展数据
 *
 * @author s.li
 * @create 2018-05-07-16:49
 */
@Data
public class OrderBook extends BaseEntity {
    /**订单ID*/
    private BigDecimal orderId;
    /**订单号*/
    private String orderNo;
    /**用户ID*/
    private BigDecimal userId;
    /**收货地址*/
    private String address;
    /**物流公司名*/
    private String mailName;
    /**物流编号*/
    private String mailCode;
    /**发货状态，1未发货，2已发货*/
    private Integer mailStatus;
    /**发货时间 */
    private Date mailTime;
    /**签到状态 1未签收 2已签收*/
    private Integer signStatus;
    /**签收时间*/
    private Date signTime;
    /**备注*/
    private String remark;

    //===============
    //收货地址数据
    private Map<String,String> addressMap;

    public Map<String,String> getAddressMap(){
        String addr = this.getAddress();
        if(StringUtils.isNotEmpty(addr)){
            this.addressMap = new HashMap<>();
            String[] arr = addr.split(",");
            if(arr.length>3){
                this.addressMap.put("userName",arr[0]);
                this.addressMap.put("address",arr[1]);
                this.addressMap.put("mobile",arr[2]);
                this.addressMap.put("postCode",arr[3]);
            }
        }
        return this.addressMap;
    }
}
